using Microsoft.Xna.Framework;

namespace Blood_Siege
{
    //The options screen is brought up over the top of the main menu
    //screen, and gives the user a chance to configure the game
    //in various hopefully useful ways.
    class OptionsMenuScreen : MenuScreen
    {
        MenuEntry AlexMenuEntry;
        MenuEntry languageMenuEntry;
        MenuEntry MusicMenuEntry;
        MenuEntry VolumeMenuEntry;

        enum Alex
        {
            Yes,
            Probably,
            Definately,
            No_Doubt_In_My_Mind,
            No____LOL_JK,
        }

        static Alex currentUngulate = Alex.Yes;

        static string[] languages = { "English", "Portuguese"};
        static int currentLanguage = 0;

        static bool Music = true;

        static int Volume = 25;

        //Constructor.
        public OptionsMenuScreen()
            : base("Options")
        {
            // Create our menu entries.
            AlexMenuEntry = new MenuEntry(string.Empty);
            languageMenuEntry = new MenuEntry(string.Empty);
            MusicMenuEntry = new MenuEntry(string.Empty);
            VolumeMenuEntry = new MenuEntry(string.Empty);

            SetMenuEntryText();

            MenuEntry backMenuEntry = new MenuEntry("Back");

            // Hook up menu event handlers.
            AlexMenuEntry.Selected += AlexMenuEntrySelected;
            languageMenuEntry.Selected += LanguageMenuEntrySelected;
            MusicMenuEntry.Selected += MusicMenuEntrySelected;
            VolumeMenuEntry.Selected += VolumeMenuEntrySelected;
            backMenuEntry.Selected += OnCancel;
            
            // Add entries to the menu.
            MenuEntries.Add(AlexMenuEntry);
            MenuEntries.Add(languageMenuEntry);
            MenuEntries.Add(MusicMenuEntry);
            MenuEntries.Add(VolumeMenuEntry);
            MenuEntries.Add(backMenuEntry);
        }


        //Fills in the latest values for the options screen menu text.
        void SetMenuEntryText()
        {
            AlexMenuEntry.Text = "Is Alex Gay?: " + currentUngulate;
            languageMenuEntry.Text = "Language: " + languages[currentLanguage];
            MusicMenuEntry.Text = "Music: " + (Music ? "on" : "off");
            VolumeMenuEntry.Text = "Volume: " + Volume;
        }

        //Event handler for when the Ungulate menu entry is selected.
        void AlexMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            currentUngulate++;

            if (currentUngulate > Alex.No____LOL_JK)
                currentUngulate = 0;

            SetMenuEntryText();
        }


        //Event handler for when the Language menu entry is selected.
        void LanguageMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            currentLanguage = (currentLanguage + 1) % languages.Length;

            SetMenuEntryText();
        }


        //Event handler for when the Frobnicate menu entry is selected.
        void MusicMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            Music = !Music;

            SetMenuEntryText();
        }



        //Event handler for when the Elf menu entry is selected.
        void VolumeMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            Volume++;

            SetMenuEntryText();
        }
    }
}
